package model;

import net.sf.vcard4j.java.type.ADR;

public class AddressWrapper {
	
	/**
	 * example:
	 * 
	 * ADR;DOM;HOME:;;liechtensteinstr. 98 / 11;wien;;1090;
	 * 
	 * PO BOX;
	 * Extended Address;
	 * Street Address;
	 * Locality
	 * Region
	 * PostalCode
	 * Country
	 * 
	 */
	
	private ADR address;
	
	public AddressWrapper(ADR address) {
		this.address = address;
	}
	
	public AddressWrapper() {}
	
	public boolean existsStreetAddress() {
		if(getStreet() == null || getStreet().trim().length() == 0) return false;
		return true;
	}
	
	public String getStreet() {
		return address.getStreet();
	}
	
	public void setStreet(String name) {
		address.setStreet(name);
	}
	
	public boolean existsLocality() {
		if(getLocality() == null || getLocality().trim().length() == 0) return false;
		return true;
	}
	
	public String getLocality() {
		return address.getLocality();
	}
	
	public void setLocality(String loc) {
		this.address.setLocality(loc);
	}
		
	public boolean existsRegion() {
		if(getRegion() == null || getRegion().trim().length() == 0) return false;
		return true;
	}
	
	public String getRegion() {
		return address.getRegion();
	}
	
	public void setRegion(String name) {
		address.setRegion(name);
	}
	
	public boolean existsPostalCode() {
		if(getPostalCode() == null || getPostalCode().trim().length() == 0) return false;
		return true;
	}
	
	public String getPostalCode() {
		return address.getPcode();
	}
	
	public void setPostalCode(String code) {
		address.setPcode(code);
	}
	
	public boolean existsCountryName() {
		if(getCountryName() == null || getCountryName().trim().length() == 0) return false;
		return true;
	}
	
	public String getCountryName() {
		return address.getCountry();
	}
	
	public void setCountryName(String name) {
		address.setCountry(name);
	}
	
	public String print() {
		StringBuffer out = new StringBuffer();
		out.append("street:\t\t");
		if(existsStreetAddress()) out.append(getStreet());
		out.append("\n");
		out.append("locality:\t\t");
		if(existsLocality()) out.append(getLocality());
		out.append("\n");
		out.append("region:\t\t");
		if(existsRegion()) out.append(getRegion());
		out.append("\n");
		out.append("postalCode:\t\t");
		if(existsPostalCode()) out.append(getPostalCode());
		out.append("\n");
		out.append("countryName:\t");
		if(existsCountryName()) out.append(getCountryName());
		out.append("\n");
		return out.toString();
	}
	
}